 ///
 /// @file    new.cc
 /// @author  lemon(haohb13@gmail.com)
 /// @date    2016-02-24 19:36:41
 ///
 
#include <stdlib.h>
#include <iostream>

using std::cout;
using std::endl;

// malloc与new的差别是: new能够进行初始化, malloc只是开辟了空间

int test0(void)
{
	int * pa = (int *) malloc(sizeof(int));
	*pa = 3;
	free(pa);

	return 0;
}

int main(void)
{
	int *pa = new int(3);
	*pa = 10;

	cout << *pa << endl;

	delete pa;


	int *pb = new int[10];// 默认进行了初始化

	for(int i = 0; i != 10; ++i)
	{
		cout << pb[i] << endl;
	}

	delete [] pb;

	return 0;
}
